// pages/fee/fee.js
const app = getApp();
Page({
  data: {
    orderid: ''
  },
  onLoad: function (options) {
    var that = this;
    // 页面初始化 options为页面跳转所带来的参数
    var orderid = options.orderid;
    that.setData({
      orderid: orderid,
    })
  },
  onReady: function () {
    // 页面渲染完成
  },
  onShow: function () {
    // 页面显示
  },

  formSubmit: function (e) {
    let that = this;
    let distance = e.detail.value.roadlLength;
    let moneyGas = e.detail.value.oilFee
    let moneyPass = e.detail.value.roadFee;
    let moneyPunish = e.detail.value.faKuan;
    let moneyOther = e.detail.value.otherFee;
    let orderid = that.data.orderid;
    wx.request({
      url: 'http://47.111.122.217:9001/transport/transportResult/create',
      method: 'post',
      data: {
        "id": orderid,
        "distance" : distance,
        "moneyGas" : moneyGas,
        "moneyPass" : moneyPass,
        "moneyPunish" : moneyPunish,
        "moneyOther" : moneyOther
      },
      header: {
        'content-type': 'application/json' // 默认值
      },
      success(res) {
        if (res.data.success) {
          wx.showToast({
              title: '随车清单创建成功',
              icon: 'success',
              duration: 2000
            }),
            wx.navigateTo({
              url: '../order/order',
            })
        } else {
          wx.showToast({
            title: '出错了',
            icon: 'fail',
            duration: 2000
          })
          return false;
        }
      }
    })
  }
})